//
//  AnmideViewController.m
//  livingDesign
//
//  Created by dlios on 15-2-3.
//  Copyright (c) 2015年 怡居. All rights reserved.
//

#import "AnmideViewController.h"
#import "NewestViewController.h"
@interface AnmideViewController ()

@end

@implementation AnmideViewController
@synthesize timer;
@synthesize splashImageView;
@synthesize nav;
@synthesize myviewcontroller;
int flag;
NSTimer *timer;

//- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
//{
//    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
//    if (self) {
//        // Custom initialization
//    }
//    return self;
//}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
      CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
    UIView *view = [[UIView alloc] initWithFrame:appFrame];
     view.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
    self.view = view;
    [view release];
     flag = 0;
    splashImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yieryi.jpg"]];
    splashImageView.frame = CGRectMake(0, 0, 768, 1004);
    [self.view addSubview:splashImageView];
    timer = [NSTimer scheduledTimerWithTimeInterval:0.6 target:self selector:@selector(addLabel) userInfo:nil repeats:YES];
    myviewcontroller = [[NewestViewController alloc] init];
    myviewcontroller.view.alpha = 0.0;
//    nav = [[UINavigationController alloc] init];
//    [nav pushViewController:myviewcontroller animated:NO];
    [self.view addSubview:nav.view];
    timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(fadeScreen) userInfo:nil repeats:NO];

}
- (void)addLabel{
    
    flag++;
    if (flag <=5) {
//        UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(200+50*flag,600,40, 40)];
        UIImageView *img = [[UIImageView alloc] init];
//        img.frame = CGRectMake(20+60*flag,300,50, 50);
        img.backgroundColor = [UIColor yellowColor];
        [UIView transitionWithView:img duration:2.f options: UIViewAnimationOptionTransitionCurlDown  animations:^{
            img.frame = CGRectMake(20+60*flag,300,50, 50);

                  } completion:^(BOOL finished) {
        
                   }];
//        label1.text = @"123";
//        label1.font = [UIFont systemFontOfSize:23];
//        label1.textColor = [UIColor whiteColor];
        [splashImageView addSubview:img];
//        [label1 release];
        [img release];
    }
    
}

- (void)fadeScreen
{
    [UIView beginAnimations:nil context:nil]; // begins animation block
    // 动画存在时间
    [UIView setAnimationDuration:5.0];        // sets animation duration
    [UIView setAnimationDelegate:self];        // sets delegate for this block
    [UIView setAnimationDidStopSelector:@selector(finishedFading)];   // calls the finishedFading method when the animation is done (or done fading out)
    self.view.alpha = 0.0;       // Fades the alpha channel of this view to "0.0" over the animationDuration of "0.75" seconds
    [UIView commitAnimations];   // commits the animation block.  This Block is done.
}


- (void) finishedFading
{
    
    [UIView beginAnimations:nil context:nil]; // begins animation block
    
    [UIView setAnimationDuration:0.75];        // sets animation duration
    self.view.alpha = 1.0;   // fades the view to 1.0 alpha over 0.75 seconds
    myviewcontroller.view.alpha = 1.0;
    [UIView commitAnimations];   // commits the animation block.  This Block is done.
    
    for(UIView *mylabelview in [self.view subviews])
    {
        if ([mylabelview isKindOfClass:[UILabel class]]) {
            [mylabelview removeFromSuperview];
        }
    }
    
    [splashImageView removeFromSuperview];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
